package com.cn.runtime;

import org.junit.Test;

public class RuntimeTest {
    @Test
    public void test(){
        Runtime runtime = Runtime.getRuntime();
        long totalMemory = runtime.totalMemory();
        System.out.println("总内存 (Total Memory): " + totalMemory / (1024 * 1024) + " MB");
        long freeMemory = runtime.freeMemory();
        System.out.println("空闲内存 (Free Memory): " + freeMemory / (1024 * 1024) + " MB");
        long maxMemory = runtime.maxMemory();
        System.out.println("最大内存 (Max Memory): " + maxMemory / (1024 * 1024) + " MB");

        runtime.gc();
        System.out.println("已建议JVM进行垃圾回收...");


    }

}
